{% extends 'base.html' %}

{% block title %}
    主页
{% endblock %}

{% block link %}
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
{% endblock %}

{% block nav %}
    <!--导航栏开始-->
    <div class="nav">
        <nav class="navbar navbar-inverse">
            <div class="container-fluid container">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                            data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="">网络科技</a>
                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">

                        <li><a href="">上传文件</a></li>
                        <li><a href="">推荐</a></li>
                    </ul>
                    <div class="col-md-offset-4">
                        <form class="navbar-form navbar-left" action="" method="get">
                            <div class="form-group">
                                <input type="text" class="form-control" name="kw" placeholder="请输入搜索内容……">
                            </div>
                            <button type="submit" class="btn btn-default">搜 索</button>
                        </form>
                    </div>
                    <ul class="nav navbar-nav navbar-right">
                        {% if session['user_email'] %}
                            <li>
                                <a href="#"><span>Hi~，</span>{{ session['user_email'] }}</a>
                            </li>
                            <li><a href="{{ url_for('logout') }}">退出登录</a></li>
                        {% else %}
                            <li>
                                <a id="index_login" href="{{ url_for('login') }}">登录</a>
                            </li>
                        {% endif %}
                    </ul>
                </div><!-- /.navbar-collapse -->
            </div><!-- /.container-fluid -->
        </nav>
    </div>
    <!--导航栏结束-->
{% endblock %}

{% block main %}
    <div class="container-fluid">
        <h1 class="text-center">Welcome ！</h1>
        <img src="{{ url_for('static', filename='/img/1057899183.jpg') }}" style="width: 100%;">
    </div>
{% endblock %}

{% block footer %}
    <script type=text/javascript>$SCRIPT_ROOT = {{ request.script_root|tojson|safe }};</script>
    <script type="text/javascript">
        var maxTime = 60*10; // seconds
        var time = maxTime;
        $('body').on('keydown mousedown mousewheel mousemove click', function (e) {
            time = maxTime; // reset
        });
        var intervalId = setInterval(function () {
            time--;
            if (time <= 0 && ("{{ session.get('user_email') }}" !== 'None')) {
                ShowInvalidLoginMessage();
                clearInterval(intervalId);
            }
        }, 1000);

        function ShowInvalidLoginMessage() {
            // 清除session
            // 提示用户
            $.ajax({
                url: '{{ url_for('logoutTime') }}',
                type: 'post',
                data: {'user_mail': "{{session.get('user_email')}}"},
                dataType: 'json',
                success: function (data) {
                        console.log(data.result)
                },
                error: function (data) {
                    {#alert('操作失败，请重试！')#}
                }
            });
            {#alert('那么长时间没动弹，退出喽！');#}
        }
    </script>
    <script crossorigin="anonymous" integrity="sha384-LVoNJ6yst/aLxKvxwp6s2GAabqPczfWh6xzm38S/YtjUyZ+3aTKOnD/OJVGYLZDl"
            src="https://lib.baomitu.com/jquery/3.5.0/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"
            integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
            crossorigin="anonymous"></script>
{% endblock %}